package com.stars.questions.deptQuestion.publish.controller;

import com.stars.base.controller.BaseController;
import com.stars.base.entity.Result;
import com.stars.questions.deptQuestion.publish.entity.Reply;
import com.stars.questions.deptQuestion.publish.service.PublishService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * 问卷发布，填写提交控制器
 */
@RestController
@RequestMapping("/publish")
public class PublishController extends BaseController {

    private final PublishService publishService;

    public PublishController(PublishService publishService) {
        this.publishService = publishService;
    }

    @GetMapping("/getQuestion")
    public Result getQuestion() {
        return Result.success(publishService.loadQuestion());
    }

    /**
     * 保存数据
     * @return 保存问卷结果
     */
    @RequestMapping("/save")
    public Result save(@RequestBody Reply reply){
        return publishService.saveReply(super.getRequest(),reply);
    }

}
